package com.freight.order.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.freight.core.common.annotation.SystemLog;
import com.freight.core.common.enums.LogType;
import com.freight.core.common.utils.PageUtil;
import com.freight.core.common.utils.ResultUtil;
import com.freight.core.common.vo.PageVo;
import com.freight.core.common.vo.Result;
import com.freight.order.dto.PcQuotationDto;
import com.freight.order.entity.OrderGoods;
import com.freight.order.service.PcQuotationRecordService;
import com.freight.order.vo.PlatQuotationRecordVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;


@Slf4j
@RestController
@Api(description = "平台端 --- 平台报价接口")
@RequestMapping("/freight/pcQuotationRecord")
@Transactional
public class PcQuotationRecordController {

    @Autowired
    private PcQuotationRecordService pcQuotationRecordService;


    @RequestMapping(value = "/entrustDriver", method = RequestMethod.POST)
    @ApiOperation(value = "平台委托司机-----")
    @SystemLog(description = "平台委托司机承运", type = LogType.OPERATION)
    public Result<OrderGoods> entrustDriver(PcQuotationDto pcQuotationDto) {
        pcQuotationRecordService.entrustDriver(pcQuotationDto);
        return ResultUtil.success("操作成功");
    }

    @RequestMapping(value = "/platformQuotationRecord", method = RequestMethod.POST)
    @ApiOperation(value = "平台端 --- 根据货源获取报价记录")
    public Result<Page<PlatQuotationRecordVo>> platformQuotationRecord(Long orderGoodsId, PageVo pageVo) {
        Page<PlatQuotationRecordVo> page = pcQuotationRecordService.platformQuotationRecord(orderGoodsId, PageUtil.initMpPage(pageVo));
        return new ResultUtil<Page<PlatQuotationRecordVo>>().setData(page);
    }

    @RequestMapping(value = "/companyplatformQuotationRecord", method = RequestMethod.POST)
    @ApiOperation(value = "货主端 --- 根据货源获取报价记录")
    public Result<Page<PlatQuotationRecordVo>> companyplatformQuotationRecord(Long orderGoodsId, PageVo pageVo) {
        Page<PlatQuotationRecordVo> page = pcQuotationRecordService.companyplatformQuotationRecord(orderGoodsId, PageUtil.initMpPage(pageVo));
        return new ResultUtil<Page<PlatQuotationRecordVo>>().setData(page);
    }

}
